#!/usr/bin/env python
#--*-- coding: utf-8 --*--

from Tkinter import *;

# 主方法。
def main():
    app = Application()
    # 设置窗口标题:
    app.master.title('Hello World')
    # 主消息循环:
    app.mainloop()

# 主类
class Application(Frame):
    def __init__(self, master=None):
        Frame.__init__(self, master);
        self.grid(padx = 5, pady = 5);
        self.createWidgets();
        # self.bingEvents();

    def createWidgets(self):
        # 定位窗口位置。
        self.master.geometry("-0+0");
        self.names = [];
        name = Label(self, text = "任务名称", anchor = W, width = 20, justify = CENTER, compound = LEFT, padx = 5);
        name.grid(row = 0, column = 0);
        time = Label(self, text = "开始时间", anchor = W, width = 20, justify = LEFT, padx = 5);
        time.grid(row = 0, column = 1);
        self.names.append((name, time));
        name = Label(self, text = "任务名称", anchor = W, width = 20, justify = CENTER, compound = LEFT, padx = 5);
        name.grid(row = 1, column = 0);
        time = Label(self, text = "开始时间", anchor = W, width = 20, justify = LEFT, padx = 5);
        time.grid(row = 1, column = 1);
        self.names.append((name, time));
        name = Label(self, text = "任务名称", anchor = W, width = 20, justify = CENTER, compound = LEFT, padx = 5);
        name.grid(row = 2, column = 0);
        time = Label(self, text = "开始时间", anchor = W, width = 20, justify = LEFT, padx = 5);
        time.grid(row = 2, column = 1);
        self.names.append((name, time));
        name = Label(self, text = "任务名称", anchor = W, width = 20, justify = CENTER, compound = LEFT, padx = 5);
        name.grid(row = 3, column = 0);
        time = Label(self, text = "开始时间", anchor = W, width = 20, justify = LEFT, padx = 5);
        time.grid(row = 3, column = 1);
        self.names.append((name, time));

        button = Button(self, text = "退出", command = self.quit, takefocus = True);
        button.grid(row = 4, column = 0, columnspan = 2, sticky=W+E+N+S, padx = 5);
# self.bind_class('Entry', '<FocusIn>', self.focusEntry);

    def focusEntry(self, event):
        event.widget.var.set("");

    def testEvent(self, why, when, what):
        print("Peter");
        self.other.set("peter: " + why + ", " + when + ", " + what);
        return True;

    def nameClick(self):
        self.other.set("some");

    def close(self):
        print(self.nameText.get());
        self.quit();

main();
